﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SchemaDeploy
{
    public class CDirList : List<CDir>
    {
        internal CDirList(int count) : base(count) { }
        internal CDirList(CVersionFileList all, string parent) : this(all, all.DirTops, parent) { }
        internal CDirList(CVersionFileList all, List<string> subfolders, string parent) : base(subfolders.Count)
        {
            foreach (var i in subfolders)
                if (i != parent && i.StartsWith(parent))
                    this.Add(new CDir(all.InDir(i), parent, i));
        }


        private List<string> _names;
        public List<string> Names
        {
            get
            {
                if (null == _names)
                {
                    _names = new List<string>(this.Count);
                    foreach (var i in this)
                        _names.Add(i.Name);
                    return _names;
                }
                return _names;
            }
        }
    }
}
